<?php if (!defined('THINK_PATH')) exit(); /*a:4:{s:95:"E:\phpStudy\PHPTutorial\WWW\new_project\public/../application/admin\view\news\categorylist.html";i:1539399149;s:82:"E:\phpStudy\PHPTutorial\WWW\new_project\application\admin\view\layout\default.html";i:1541398045;s:79:"E:\phpStudy\PHPTutorial\WWW\new_project\application\admin\view\common\meta.html";i:1541398045;s:81:"E:\phpStudy\PHPTutorial\WWW\new_project\application\admin\view\common\script.html";i:1541398045;}*/ ?>
<!DOCTYPE html>
<html lang="<?php echo $config['language']; ?>">
    <head>
        <meta charset="utf-8">
<title><?php echo (isset($title) && ($title !== '')?$title:''); ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="renderer" content="webkit">

<link rel="shortcut icon" href="/assets/img/favicon.ico" />
<!-- Loading Bootstrap -->
<link href="/assets/css/backend<?php echo \think\Config::get('app_debug')?'':'.min'; ?>.css?v=<?php echo \think\Config::get('site.version'); ?>" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
<!--[if lt IE 9]>
  <script src="/assets/js/html5shiv.js"></script>
  <script src="/assets/js/respond.min.js"></script>
<![endif]-->
<script type="text/javascript">
    var require = {
        config:  <?php echo json_encode($config); ?>
    };
</script>
    </head>

    <body class="inside-header inside-aside <?php echo defined('IS_DIALOG') && IS_DIALOG ? 'is-dialog' : ''; ?>">
        <div id="main" role="main">
            <div class="tab-content tab-addtabs">
                <div id="content">
                    <div class="row">
                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                            <section class="content-header hide">
                                <h1>
                                    <?php echo __('Dashboard'); ?>
                                    <small><?php echo __('Control panel'); ?></small>
                                </h1>
                            </section>
                            <?php if(!IS_DIALOG && !$config['fastadmin']['multiplenav']): ?>
                            <!-- RIBBON -->
                            <div id="ribbon">
                                <ol class="breadcrumb pull-left">
                                    <li><a href="dashboard" class="addtabsit"><i class="fa fa-dashboard"></i> <?php echo __('Dashboard'); ?></a></li>
                                </ol>
                                <ol class="breadcrumb pull-right">
                                    <?php foreach($breadcrumb as $vo): ?>
                                    <li><a href="javascript:;" data-url="<?php echo $vo['url']; ?>"><?php echo $vo['title']; ?></a></li>
                                    <?php endforeach; ?>
                                </ol>
                            </div>
                            <!-- END RIBBON -->
                            <?php endif; ?>
                            <div class="content">
                                <!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="/assets/plug/layui-v2.4.3/layui/css/layui.css">
    <link href="/assets/plug/Hui-iconfont/1.0.9/iconfont.min.css" rel="stylesheet" type="text/css">
    <title>Document</title>
    <style>
        .xinwen{
            width: 100%;
            height: 67px;
            padding: 15px;
            background: #e8edf0;
            border-color: #e8edf0;
        }
        .xinwen h6 {
            font-weight: bold;
            color: #333333;
            font-size: 13px;
            padding: 0;
            margin: 0;
        }
        .xinwen p {
            margin-top: 5px;
        }
        .caozuo {
            width: 100%;
            height: 51px;
            background-color: #fff;
            padding-top:10px;
        }
        .caozuo .addcategory, .caozuo .delcategory, .caozuo .caozuo_search {
            display: inline-block;
            color: #fff;
            background-color: #18bc9c;
            width: 62px;
            height: 30px;
            text-align: center;
            line-height: 30px;
            border-radius: 5px;

        }
        .caozuo .caozuo_search {
            margin-left: 55%;
            background-color: #fff;
            width:  290px;
        }
        .caozuo .caozuo_search input {
            height: 30px;
            padding-left: 7px;
            color: #000;
        }
        .caozuo .caozuo_search span {
            display: inline-block;
            margin-left: 10px;
            width: 60px;
            height: 30px;
            background-color: #18bc9c;
            border-radius: 5px;
        }
        .caozuo .addcategory {
            margin-left: 20px;
        }
        .caozuo .delcategory {
            background-color: #e74c3c;
        }

        table{
            padding-left: 20px;
            width: 100%;
            background-color: #fff;
        }
        table tr:nth-child(1){
            height: 40px;
            background-color: #f1f4f6;
            color: #333333;
        }
        table tr:nth-child(1) td{
           border: 1px solid #ddd;
            font-weight: bold;
        }
        table tr td{
            width: 100px;
            height: 35px;
            border: 1px solid rgba(242, 242, 242, 0.4);
            text-align: center;
            font-size:12px;
            border: 1px solid #ddd;
        }
        table tr td:nth-child(1){
            width: 35px;
        }
        table tr td:nth-child(2){
            width: 35px;
        }
        table tr td:nth-child(4){
            width: 35px;
        }
        table tr td:nth-child(5){
            width: 40px;
        }
        table tr td:nth-child(6){
            width: 40px;
        }
        table tr {
            width: 100%;
            height: 35px;
        }

        .pagination > li > a, .pagination > li > span {
            color: #0080d6 !important;
            border: 1px solid #0080d6 !important;
            margin-left: 2px;
        }
        .delproductcate {
            color: red;
        }
        .edit_button {
            color: #4dc6ff;
        }
        .news_mask_content {
            text-align: center;
            margin-top: 10px;
        }
        .news_mask_content div:nth-child(1) {
            background-color: #009f95;
            height: 42px;
            text-align: left;
            padding-left: 10px;
            color: #fff;
            line-height: 42px;
        }
        .news_mask_content div:nth-child(2) {
            text-align: left;
        }
        .news_mask_content div:nth-child(2) span {
            display: inline-block;
            width: 110px;
            height: 38px;
            background-color: #e6e6e6;
            text-align: center;
            line-height: 38px;
            border: 1px solid #f6f6f6;
            margin-left: 20px;
        }
        .news_mask_content div:nth-child(2) {
            margin-top: 30px;
        }
        .news_mask_content div:nth-child(2) input {
            width: 300px;
            height: 37px;
            padding-left: 10px;
            margin-top: -2px;
        }
    </style>
</head>
<body>
    <div class="xinwen">
        <h6>新闻分类</h6>
        <p>一个管员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成</p>
    </div>
    <div class="caozuo">
        <div class="addcategory"><span><i class="Hui-iconfont">&#xe600;</i>添加</span></div>
        <div class="delcategory"><span><i class="Hui-iconfont">&#xe609;</i>删除</span></div>
        <div class="caozuo_search"><input type="text" value="<?php echo \think\Session::get('newscate:keywords:search'); ?>" name="search"><span id="searchs"><i class="Hui-iconfont">&#xe665;</i>搜索</span></div>
    </div>
    <div class="category">
        <table>
            <tr>
                <td><input type="checkbox" class="abc" name="SelectAll" ></td>
                <td>ID</td>
                <td>分类名称</td>
                <td>创建时间</td>
                <td>更新时间</td>
                <td>操作</td>
            </tr>
            <?php if(is_array($newscate) || $newscate instanceof \think\Collection || $newscate instanceof \think\Paginator): if( count($newscate)==0 ) : echo "" ;else: foreach($newscate as $key=>$value): ?>
            <tr <?php if($key%2 == 0): ?>style="background-color: #f5f5f5"<?php endif; ?>>
                <td><input type="checkbox" name="selectOne" value="<?php echo $value['id']; ?>"></td>
                <td><?php echo $value['id']; ?></td>
                <td><?php echo $value['catename']; ?></td>
                <td><?php echo date("Y-m-d H:i:s", $value['create_time']); ?></td>
                <td><?php echo date("Y-m-d H:i:s", $value['update_time']); ?></td>
                <td><a class="edit_button" index="<?php echo $value['id']; ?>" href="javascript:void(0)"><i class="Hui-iconfont">&#xe6df;编辑</i></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a class="delproductcate" href="/admin/news/delcate?id=<?php echo $value['id']; ?>"><i class="Hui-iconfont">&#xe6e2;删除</i></a></td>
            </tr>
            <?php endforeach; endif; else: echo "" ;endif; ?>
        </table>
    </div>
    <div class="paginate"><?php echo $page; ?></div>
</body>
<script src="/assets/js/jquery-3.3.1.min.js" type="text/javascript"></script>
<script src="/assets/plug/layui-v2.4.3/layui/layui.js"></script>
<script>
    $(function () {
//        全选和全不选 
        $('input[name=SelectAll]').click(function () {
            if($('input[name=SelectAll]').hasClass('abc')){
                $('input[type=checkbox]').prop('checked', true);
                $('input[name=SelectAll]').removeClass('abc');
            }else{
                $('input[type=checkbox]').prop('checked', false);
                $('input[name=SelectAll]').addClass('abc');
            };
        })
//        批量删除
        $('.delcategory').click(function () {
            // 判断是否至少选择一项
            var checkedNum = $("input[name='selectOne']:checked").length;
            if(checkedNum == 0) {
                alert("请选择至少一项！");
                return;
            }
            // 批量选择
            if(confirm("确定要删除所选项目？")) {
                var checkedList = new Array();
                $("input[name='selectOne']:checked").each(function () {
                    checkedList.push($(this).val());
                });
            }
            $.ajax({
                url: '/admin/news/delSelectInput',
                type: 'post',
                data: {checkList: JSON.stringify(checkedList)},
                success: function (res) {
                    alert(res.info);
                    if(res.status){
                        top.location.href = '/admin/news/categorylist?ref=addtabs';
                    }
                }
            })

        })

        //搜索
        $('#searchs').click(function () {
            var searchKeywords = $('input[name=search]').val();
            $.ajax({
                url: '/admin/news/searchNewscateKeywords',
                data: {search: searchKeywords},
                type: 'post',
                success: function (res) {
                    top.location.href = '/admin/news/categorylist?ref=addtabs'
                }
            })
        })
        //        编辑
        $('.edit_button').click(function () {
            var id = $(this).attr('index');
            $.ajax({
                url: '/admin/news/editnewscate',
                type: 'get',
                data: {id: id},
                success: function (res) {
                    if(res.status) {
                        layui.use('layer', function(){
                            var layer = layui.layer;
                            layer.open({
                                type: 1,
                                title: '产品管理',
                                area: ['500px', '280px'],
                                btn: ['提交', '取消'],
                                btn1: function(index, layero){
                                    var catename = $('input[name=edit_catename]').val();
                                    var id = $('input[name=hidden_id]').val();
                                    if(!catename) {
                                        alert('分类不能为空！');
                                        return
                                    }
                                    $.ajax({
                                        url: '/admin/news/editnewscate',
                                        data: {id: id, catename: catename},
                                        type: 'post',
                                        success: function (res) {
                                            alert(res.info);
                                            if(res.status) {
                                                top.location.href = '/admin/news/categorylist?ref=addtabs';
                                            }
                                        }
                                    })
                                },
                                btn2: function(index, layero){

                                },
                                content:
                                ' <div class="news_mask_content"> '+
                                '<div><i class="Hui-iconfont">&#xe600;新增产品分类</i></div> '+
                                '<div> '+
                                '<span>分类名称</span> '+
                                '<input type="text" value="' + res.data.catename + '" name="edit_catename" placeholder="请输入分类名称"> '+
                                '<input type="hidden" name="hidden_id" value="'+ res.data.id +'">' +
                                '</div>'+
                                '</div>' //这里content是一个普通的String
                            });
                        });
                    }else{
                        alert(res.info);
                    }
                }
            })
        })

        $('.addcategory').click(function () {

            layui.use('layer', function(){
                var layer = layui.layer;
                layer.open({
                    type: 1,
                    title: '新闻管理',
                    area: ['500px', '280px'],
                    btn: ['提交', '取消'],
                    btn1: function(index, layero){
                       var catename = $('input[name=catename]').val();
                       if(!catename) {
                           alert('分类不能为空！');
                           return
                       }
                       $.ajax({
                           url: '/admin/news/addnewscate',
                           data: {catename: catename},
                           type: 'post',
                           success: function (res) {
                               alert(res.info);
                               if(res.status) {
                                   top.location.href = '/admin/news/categorylist?ref=addtabs'
                               }
                           }
                       })
                    },
                    btn2: function(index, layero){

                    },
                    content:
                    ' <div class="news_mask_content"> '+
                        '<div><i class="Hui-iconfont">&#xe600;新增新闻分类</i></div> '+
                        '<div> '+
                            '<span>分类名称</span> '+
                            '<input type="text" name="catename" placeholder="请输入分类名称"> '+
                        '</div>'+
                    '</div>' //这里content是一个普通的String
                });
            });
        })

        $('.delproductcate').click(function (event) {
            var isdel = confirm('确定要删除吗？');
            if(!isdel){
                event.preventDefault();
            }
        })
    })
</script>
</html>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script src="/assets/js/require<?php echo \think\Config::get('app_debug')?'':'.min'; ?>.js" data-main="/assets/js/require-backend<?php echo \think\Config::get('app_debug')?'':'.min'; ?>.js?v=<?php echo $site['version']; ?>"></script>
    </body>
</html>